<?php
namespace Tools\Controller;
use Common\Controller\AdminbaseController;

class AdminJobController extends AdminbaseController{
	
	protected $ab_model;
	
	public function _initialize() {
		parent::_initialize();
		$this->ab_model = M("ToolsAbout");
	}
	
	public function index(){
		$job = M('tools_job')->where("del = '0'")->order("orderlist asc,addtime desc")->select();
		$this->assign('job',$job);
		$this->display();
	}
	
	public function add(){
		if(isset($_POST['post'])){
			$_POST['addtime'] =time();
			$add = M('tools_job')->add($_POST);
			if ($add) {
				$this->success("发布成功！", U("AdminJob/index"));
			} else {
				$this->error("发布失败！");
			}
		}
		
		$this->display();
	}
	
	public function edit(){
		$id = $_GET['id'];
		$job = M('tools_job')->where("del = '0' and id = '$id'")->find();
		
		if(IS_POST){
			$id = $_POST['jid'];
			$save = M('tools_job')->where("id = '$id'")->save($_POST);
			if ($save) {
				$this->success("编辑成功！", U("AdminJob/index"));
			} else {
				$this->error("编辑失败！");
			}
		}
		
		$this->assign('job',$job);
		$this->display();
		
	}
	public function delete(){
		$id = I('id');
		$data['del'] = 1;
		$save = M('tools_job')->where("id = '$id'")->save($data);
		if ($save) {
			$this->success("删除成功！", U("AdminJob/index"));
		} else {
			$this->error("删除失败！");
		}
	}

	
	
	
}